<template>
  <div class='container'>
    <div class="coupon" v-for="(item, index) in couponList" :accesskey="index">
      <div class="coupon-left">
        <div class="price">
          {{ item.couponPrice }} 元
        </div>
        <div class="title">
          {{ item.couponTitle }}
        </div>
        <div class="status">
          {{ item._msg }}
        </div>
      </div>
      <div class="coupon-right">
        <div class="start">
          领取时间：{{ item.createTime }}
        </div>
        <div class="end">
          过期时间：{{ item.endTime }}
        </div>
        <div class="use">
          最低满：{{ item.useMinPrice }}/元可用
        </div>
        <div class="useTime" v-if="item.useTime">
          使用时间：{{ item.useTime }}
        </div>
      </div>
    </div>
  </div>
</template>


<script>
import { getCoupons } from '@/api/discount.js'

export default {
  data() {
    return {
      couponList: [],
      active: 0
    }
  },
  methods: {
    getCoupons() {
      getCoupons().then(res => {
        this.couponList = res.data
        // console.log(this.couponList);
      })
    }
  },
  created() {
    this.getCoupons()
  }
}

</script>


<style lang='scss' scoped>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.container {
  width: 100%;
  height: 100%;
  background: #f5f5f5;
}

.coupon {
  margin: 0 auto;
  width: 80%;
  height: 100px;
  background: rgb(239, 211, 211);
  border-radius: 10px;
  margin-top: 10px;
  display: flex;

  .coupon-left {
    width: 40%;
    height: 100px;
    border-radius: 10px 0 0 10px;
    background: red;

    .price {
      text-align: center;
      font-size: 30px;
      padding-top: 15px;
    }

    .title {
      text-align: center;
      font-size: 15px;
    }

    .status {
      margin: 0 auto;
      margin-top: 5px;
      text-align: center;
      font-size: 8px;
      border: 1px solid rgba(176, 173, 173, 0.797);
      border-radius: 10px;
      padding-top: 1px;
      padding-bottom: 1px;
      width: 80%;
    }
  }

  .coupon-right {
    width: 60%;
    height: 80px;
    margin-top: 10px;
    margin-left: 10px;
    display: flex;
    flex-flow: column;
    justify-content: space-between;
    font-weight: 600;    
  }
}
</style>
